﻿using Ast.Framework.Environment.AutofacUtil;
using Autofac;

namespace Ast.Framework.Environment.Extensions
{
    public class ExtensionModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            // assemblies
            var assemblies = AutofacAssemblyStore.GetAssemblies();

            // extensions
            builder.RegisterAssemblyTypes(assemblies)
                .Where(t => typeof(IExtension).IsAssignableFrom(t))
                .As<IExtension>()
                .SingleInstance();
        }
    }
}